<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button id="button"></button>
</body>

</html>
<script>
  let arr = [2, 5, 7, 6, 3, 5, 7, 5, 3, 2, 5, 7, 8, 6]
  // 获取按钮
  var button = document.querySelector("#button")
  // 添加点击事件监听器
  button.addEventListener("click", function () {
    // 点击事件处理代码
    maopao()
    console.log(arr, "arr")
  })

  function maopao () {
    let n = arr.length
    for (let i = 1; i < n; i++) {
      let current = arr[i]
      let j = i - 1
      while (j >= 0 && arr[j] > current) {
        arr[j + 1] = arr[j]
        j--
      }
      arr[j + 1] = current
    }
    return arr
  }

</script>